<html>
<head><meta charset="utf-8"><title>Rust Analyzer for Compiler Dev in NeoVim · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Rust.20Analyzer.20for.20Compiler.20Dev.20in.20NeoVim.html">Rust Analyzer for Compiler Dev in NeoVim</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="215723566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Rust%20Analyzer%20for%20Compiler%20Dev%20in%20NeoVim/near/215723566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Rust.20Analyzer.20for.20Compiler.20Dev.20in.20NeoVim.html#215723566">(Nov 05 2020 at 15:04)</a>:</h4>
<p>Hi,</p>
<p>Does anyone know how to configure rust-analyzer to run <code>x.py</code> instead of <code>cargo</code> when using an lsp under neovim?</p>
<p>Currently rust-analyzer will run <code>cargo</code> and spam vim with a bazillion errors. For some lsp vim plugins, that locks up the editor for 40 seconds at  a time.</p>
<p>There are instructions <a href="https://rustc-dev-guide.rust-lang.org/building/suggested.html#configuring-rust-analyzer-for-rustc">here</a> for vscode, but not for neovim.</p>
<p>Thanks</p>



<a name="215727134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Rust%20Analyzer%20for%20Compiler%20Dev%20in%20NeoVim/near/215727134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Rust.20Analyzer.20for.20Compiler.20Dev.20in.20NeoVim.html#215727134">(Nov 05 2020 at 15:28)</a>:</h4>
<p>By using strace, I've found that rust-analyzer looks for <code>rust-project.json</code> in the project root for its settings.</p>
<p>And then I found <a href="https://rust-analyzer.github.io/manual.html#non-cargo-based-projects">these docs</a>, but it's not clear to me how I should get rust-analyzer to use x.py.</p>
<p>What's frustrating is the linked example repo doesn't actually contain a rust-project.json.</p>



<a name="215727195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Rust%20Analyzer%20for%20Compiler%20Dev%20in%20NeoVim/near/215727195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Rust.20Analyzer.20for.20Compiler.20Dev.20in.20NeoVim.html#215727195">(Nov 05 2020 at 15:29)</a>:</h4>
<p>See: <a href="https://rustc-dev-guide.rust-lang.org/building/suggested.html#configuring-rust-analyzer-for-rustc">https://rustc-dev-guide.rust-lang.org/building/suggested.html#configuring-rust-analyzer-for-rustc</a></p>



<a name="215727319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Rust%20Analyzer%20for%20Compiler%20Dev%20in%20NeoVim/near/215727319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Rust.20Analyzer.20for.20Compiler.20Dev.20in.20NeoVim.html#215727319">(Nov 05 2020 at 15:30)</a>:</h4>
<p>I literally posted that link in my post :P</p>
<p>The instructions are for vscode only it seems.</p>



<a name="215727437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Rust%20Analyzer%20for%20Compiler%20Dev%20in%20NeoVim/near/215727437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Rust.20Analyzer.20for.20Compiler.20Dev.20in.20NeoVim.html#215727437">(Nov 05 2020 at 15:30)</a>:</h4>
<p>Oh, sorry. I thought you hadn't seen that because you were mentioning rust-project.json, which is something very different</p>



<a name="215727523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Rust%20Analyzer%20for%20Compiler%20Dev%20in%20NeoVim/near/215727523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Rust.20Analyzer.20for.20Compiler.20Dev.20in.20NeoVim.html#215727523">(Nov 05 2020 at 15:31)</a>:</h4>
<p>You'll have to figure out how to change settings of rust-analyzer then</p>



<a name="215727571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Rust%20Analyzer%20for%20Compiler%20Dev%20in%20NeoVim/near/215727571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Rust.20Analyzer.20for.20Compiler.20Dev.20in.20NeoVim.html#215727571">(Nov 05 2020 at 15:31)</a>:</h4>
<p>In whichever way neovim uses for that</p>



<a name="215727606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Rust%20Analyzer%20for%20Compiler%20Dev%20in%20NeoVim/near/215727606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Rust.20Analyzer.20for.20Compiler.20Dev.20in.20NeoVim.html#215727606">(Nov 05 2020 at 15:31)</a>:</h4>
<p>And then set the settings as explained in the rustc-dev-guide</p>



<a name="215730074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Rust%20Analyzer%20for%20Compiler%20Dev%20in%20NeoVim/near/215730074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vn-ki <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Rust.20Analyzer.20for.20Compiler.20Dev.20in.20NeoVim.html#215730074">(Nov 05 2020 at 15:47)</a>:</h4>
<p>I use coc.nvim and it has a <code>CocLocalConfig</code> just like vscode. You can put project local settings there.</p>



<a name="215730973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Rust%20Analyzer%20for%20Compiler%20Dev%20in%20NeoVim/near/215730973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Rust.20Analyzer.20for.20Compiler.20Dev.20in.20NeoVim.html#215730973">(Nov 05 2020 at 15:53)</a>:</h4>
<p>I'm hoping to get it going in vim-lsp or nvim-lspconfig. If I crack it, I will post the config.</p>



<a name="215732540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Rust%20Analyzer%20for%20Compiler%20Dev%20in%20NeoVim/near/215732540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vn-ki <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Rust.20Analyzer.20for.20Compiler.20Dev.20in.20NeoVim.html#215732540">(Nov 05 2020 at 16:03)</a>:</h4>
<p>If you are going to use vim-lsp, better use coc. ;)</p>
<p>Can save time which can be used to write code and not fight the editor.</p>



<a name="215736099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Rust%20Analyzer%20for%20Compiler%20Dev%20in%20NeoVim/near/215736099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Rust.20Analyzer.20for.20Compiler.20Dev.20in.20NeoVim.html#215736099">(Nov 05 2020 at 16:23)</a>:</h4>
<p>I've been using vim-lsp for non-compiler-projects for some time. It works fine, but I just can't get it to run x.py for rustc.</p>
<p>I also tried nvim-lspconfig. For that it looks like this should work in init.vim:</p>
<div class="codehilite"><pre><span></span><code>lua &lt;&lt;EOF
require&#39;nvim_lsp&#39;.rust_analyzer.setup {
    on_attach = require&#39;diagnostic&#39;.on_attach;
    settings = {
            [&quot;rust-analyzer.checkOnSave.overrideCommand&quot;] = { &quot;./x.py&quot;, &quot;check&quot;, &quot;--json-output&quot; }
    };
}
EOF
</code></pre></div>
<p>But alas, it doesn't. The rust-analyzer log is full of lots and lots of errors.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>